/<template>
  <div>
    <van-nav-bar
  title="详情"
  left-text="返回"
  right-text="按钮"
  left-arrow
  @click-left="onClickLeft"
  @click-right="onClickRight"
/>
    <img :src="detail.img" alt="" />
    <div>
      <h3>{{ detail.title }}</h3>
      <h3>{{ detail.text }}</h3>
      <h3>￥ {{ detail.price }} 元</h3>
      <h3>已售 {{ detail.num }} 件</h3>
    </div>
  </div>
</template>

<script>
import axios from "../config/axios.js";
export default {
  data() {
    return {
      detail: {},
    };
  },
  // mounted() {
  //   console.log(this.$route);
  //   axios
  //     .get("/goodsDetail", {
  //       params: {
  //         id: this.$route.params.id,
  //       },
  //     })
  //     .then((res) => {
  //       this.detail = res.data;
  //     });
  // },
  mounted() {
    console.log(this.$route);
    // this.$route.params.id 获取动态路由传递的参数 /detail/150000200411122264
    // this.$route.query.id 获取query传递的参数 /detail?id=150000200411122264
    axios
      .get("/goodsDetail", {
        params: {
          id: this.$route.params.id,
        },
      })
      .then((res) => {
        this.detail = res.data;
      });
  },
  methods:{
    onClickLeft(){
      this.$router.go(-1)
    },
    onClickRight(){}
  }
};
</script>

<style>
</style>